home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11029 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: swidir.switch.ch!epflnews!news
  2. From: Niels Hilbrink <niels@imacsg2.epfl.ch>
  3. Newsgroups: comp.lang.c++
  4. Subject: Q: how to create an Object without creating the whole object
  5. Date: Tue, 12 Mar 1996 11:15:37 +0100
  6. Organization: EPFL
  7. Message-ID: <31454EC9.167E@imacsg2.epfl.ch>
  8. NNTP-Posting-Host: imacsg2.epfl.ch
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; IRIX 5.3 IP22)
  13.  
  14. Hi,
  15.  
  16. Oke the problem is this (maybe it's in a FAQ but couldn't find the faq
  17. so ...):
  18.  
  19. Say you've got a class A which is composed of say 10 other class
  20. (inheritance multiple and single whatever). But if I create an object
  21. with new this class 'explodes' (all the member functions are created of
  22. all the parentclasses) so you want the initialize only those parent
  23. class you need say only class B.
  24.  
  25. How do you do that ?
  26.  
  27. something like:
  28.     
  29.     Aobj = (A*) new A::B()
  30.  
  31. But this doen't work, can anybody tell me what will ?
  32.  
  33. oh yeah this works of course :
  34.     Bobj = new B;
  35.  
  36.     Aobj = (A*) Bobj;
  37.  
  38. but I don't want that, I don't want first to  have to create a B object
  39. and "attach" it to the A object
  40.  
  41. Gr.
  42. Niels
  43.  
  44. -- 
  45.  
  46.    The most overlooked advantage to owning a computer is 
  47.    that if they foul up there's no law against wacking   
  48.    them around a little.                                 
  49.  
  50. ------------------------------------------------------------
  51. Koen D'Hondt                          Niels Hilbrink
  52. koen@dutlhs1.lr.tudelft.nl      niels@dutlcc3.lr.tudelft.nl
  53.  
  54. **** Ripley Software Development ****
  55. (finger niels@dutlcc3.lr.tudelft.nl for more information.)
  56. ------------------------------------------------------------
  57.